/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.sensor.files;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import nl.cloudfarming.client.geoviewer.LayerProvider;
import nl.cloudfarming.client.geoviewer.Palette;
import nl.cloudfarming.client.sensor.SensorDataLayerProvider;
import nl.cloudfarming.client.sensor.SensorPalette;
import org.openide.util.Lookup;

/**
 *
 * @author Timon Veenstra
 */
public class SensorPaletteSettingsPanel extends JPanel {

    private final JComboBox paletteBox = new JComboBox();

    public SensorPaletteSettingsPanel() {
        setLayout(new MigLayout("wrap 2"));

        add(new JLabel("Kies een palette: "));

        paletteBox.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Pallet 0.1 -> 0.4", "Pallet 0.1 -> 0.6", "Pallet 0.1 -> 0.8", "Pallet 0.2 -> 0.4", "Pallet 0.2 -> 0.6", "Pallet 0.2 -> 0.8", "Pallet 0.0 -> 1.0"}));
        paletteBox.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                int selected = paletteBox.getSelectedIndex();
                Palette pallete;
                switch (selected) {
                    case 0:
                        pallete = SensorPalette.PALLET01_04;
                        break;
                    case 1:
                        pallete = SensorPalette.PALLET01_06;
                        break;
                    case 2:
                        pallete = SensorPalette.PALLET01_08;
                        break;
                    case 3:
                        pallete = SensorPalette.PALLET02_04;
                        break;
                    case 4:
                        pallete = SensorPalette.PALLET02_06;
                        break;
                    case 5:
                        pallete = SensorPalette.PALLET02_08;
                        break;
                    case 6:
                        pallete = SensorPalette.PALLET00_10;
                        break;
                    default:
                        pallete = SensorPalette.PALLET01_04;
                }
                for (SensorDataLayerProvider layerProvider : Lookup.getDefault().lookupAll(SensorDataLayerProvider.class)) {
                        layerProvider.changePalette(pallete);
                }
            }
        });
        add(paletteBox);

    }
}
